<template>
  <div>
    <van-nav-bar
      title="快递单"
      left-arrow
      @click-left="$router.push('/home')"
    />

    <!-- 搜索 -->
    <van-search
      v-model="value"
      placeholder="快递单号"
       shape="round"
      show-action
      @search="onSearch"
    >
      <template #action>
        <div style="color: #003399" @click="onSearch(value)">搜索</div>
      </template>
    </van-search>
    <div class="describe">
      <div v-for="item in expressArr" :key="item.id" class="order-content">
        <div class="describe-header">
          <div class="des-hea-title">快递单号：{{ item.orderCode }}</div>
          <img src="../assets/images/jiantou.png" alt="" height="16px" />
        </div>
        <div class="content">
          <img src="../assets/images/yhImg_03.gif" alt="" />
          <div class="cont-right">
            <h4>{{ item.title }}</h4>
            <div class="cont-center">
              <span class="span1">下单时间</span>
              <span>{{ item.createTime }}</span>
            </div>
            <div class="bottom">
              <span class="span1">收货人</span>
              <span>{{ item.consignee }}</span>
            </div>
            <div class="bottom">
              <span class="span1">发货人</span>
              <span>{{ item.consignor }}</span>
            </div>
          </div>
        </div>
        <div class="btn">
          <button @click="pjclick(item)" v-if="item.star == 0" class="pjbtn">
            评价
          </button>
          <button
            @click="ckClick(item)"
            v-else-if="item.star == 1"
            class="ckpj"
          >
            查看评价
          </button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { expressAPI } from "../request/api";
export default {
  data() {
    return {
      expressArr: [],
      // 搜索
      value: "",
    //  1355354548949311508
    };
  },
 methods: {
     onSearch(val) {
      //  console.log(val);
      if (val) {
        expressAPI({
          keyword: val,
          current: 1,
          size: 40,
        }).then(res => {
         this.expressArr = res.data.records;
        });
      } else {
        expressAPI({
          keyword: val,
          current: 1,
          size: 40,
        }).then(res => {
          this.expressArr = res.data.records;
        });
      }
    },
    pjclick(item) {
      this.$router.push({
        name: "expressPJ",
        query: {
          item: item,
        },
      });
    },

    ckClick(item) {
      this.$router.push({
        name: "ExpressDetail",
        query: {
          item: item,
        },
      });
    },
  },
  created() {
    expressAPI().then((res) => {
        // console.log(res);
      if (res.errCode == 0) {
        this.expressArr = res.data.records;
      }
    });
  },

 
}
</script>
 
<style lang = "less" scoped>
/deep/.van-nav-bar {
  background-color: #003399;

  .van-nav-bar__title,
  .van-icon-arrow-left::before {
    color: #fff;
  }
}
.describe {
  margin-top: 10px;
  width: 100%;
  box-sizing: border-box;
  .describe-header {
    padding: 0 15px;
    height: 60px;
    line-height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e5e5;
  }
}

.btn {
  border-top: 1px solid #e5e5e5;
  overflow: hidden;
  background-color: #fff;
  button {
    float: right;
    margin: 10px;
    border: 0;
    width: 80px;
    height: 40px;
    border-radius: 20px;
  }
  .fhbtn {
    color: #fff;
    background-color: #294d95;
  }
  .shbtn {
    border: 1px solid #4a68e1;
    color: #4a68e1;
    background-color: #fff;
  }
  .pjbtn {
    color: #fff;
    background-color: #ffcc33;
  }
  .ckpj {
    border: 1px solid #ffcc33;
    color: #ffcc33;
    background-color: #fff;
  }
}

.order-content {
  padding: 0 15px;
  box-sizing: border-box;
  width: 100%;
  margin-bottom: 10px;
  background-color: #fff;
}
.content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  padding: 20px 0;
  img {
    width: 25%;
  }

  .cont-right {
    .cont-center {
      margin: 10px 0;
    }
    .span1 {
      color: #b0b0b0;
      margin-right: 20px;
    }
    .bottom {
      margin-bottom: 10px;
    }
    h4 {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
}
</style>